% TABLE3B.M

clear;
randn('seed',123)

% Table 1: Daily regular gasoline price, 2003-2008
load data3b.txt;
varx=data3b(:,3); % Variance of the n individual regressors

% Variance of dependent variable in original joint regression
vary=0.352999;           % Set manually
%vary=5.837638;           
%vary=4.674925;         
%vary=3.201097;           
%vary=5.712727;           
    
% Original regressor matrix for joint regression excluding intercept
load X3b.txt; [T,n]=size(X3b);

nrep=100000;                           % Simulation trials -> inf
for r=1:nrep

    y=sqrt(vary).*randn(T,1);
    X=zeros(size(X3b));
    for i=1:T
        for j=1:n
            if X3b(i,j)~=0
                X(i,j)=sqrt(varx(j,1)).*randn(1,1);
            end;
        end;
    end;
    
    % Take supremum over n t-statistics for each trial i:
    tstat=olsjoint(y,[ones(T,1) X]); 
    tmax(r,1)=max(tstat);
    clear y X tstat;
end;

% Compute 5% and 10% one-sided critical values of the distribution of the 
% sup-t-statistic allowing for data mining
%disp([n prctile(tmax,(1-0.05)*100)])
%disp([n prctile(tmax,(1-0.10)*100)])

% P-values
sum(sort(tmax)>2.02)/length(tmax)

